#-*- coding:utf-8 -*-
import _twitter

"""
這是 Twitter 的介面
"""

twitter = _twitter.Api()

def api(action, args):
    global twitter    
        
    if action == "use_token":
        try:
            twitter = _twitter.Api(args['consumer_key'],
                                   args['consumer_secret'],
                                   args['access_token_key'],
                                   args['access_token_secret']
                                    )
        except KeyError:
            print "need <consumer_key>, <consumer_secret>, <access_token_key> and <access_token_secret>."

    elif action == "share":
            twitter.PostUpdate(args['content'])
    else:
        print action, "is not exist."
